﻿using System;
using ParserGenerator.GrammarConstruction;

namespace ParserGenerator.ParserConstruction
{
    [Serializable]
    public sealed class ParserAutomatonGoto
    {
        public int Number { get; }
        public ParserAutomatonGotosTable Table { get; }
        public ParserAutomatonState State { get; }
        public GrammarNonterminalSymbol Symbol { get; }
        public ParserAutomatonState Target { get; }

        internal ParserAutomatonGoto(int number, ParserAutomatonGotosTable table, ParserAutomatonState state, GrammarNonterminalSymbol symbol, ParserAutomatonState target)
        {
            if (number < 0)
                throw new ArgumentOutOfRangeException(nameof(number), SR.GotoNumberMustBeNonNegative);
            if (table == null)
                throw new ArgumentNullException(nameof(table));
            if (state == null)
                throw new ArgumentNullException(nameof(state));
            if (symbol == null)
                throw new ArgumentNullException(nameof(symbol));
            if (target == null)
                throw new ArgumentNullException(nameof(target));
            Number = number;
            Table = table;
            State = state;
            Symbol = symbol;
            Target = target;
        }

        public sealed override string ToString()
        {
            return "goto " + Target.Number;
        }
    }
}
